/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author msc
 */
@Entity
@Table(name = "Position")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Position.findAll", query = "SELECT p FROM Position p"),
    @NamedQuery(name = "Position.findByPositionId", query = "SELECT p FROM Position p WHERE p.positionId = :positionId"),
    @NamedQuery(name = "Position.findByPositionName", query = "SELECT p FROM Position p WHERE p.positionName = :positionName"),
    @NamedQuery(name = "Position.findByPrc", query = "SELECT p FROM Position p WHERE p.prc = :prc"),
    @NamedQuery(name = "Position.findBySrc", query = "SELECT p FROM Position p WHERE p.src = :src"),
    @NamedQuery(name = "Position.findByBsc", query = "SELECT p FROM Position p WHERE p.bsc = :bsc"),
    @NamedQuery(name = "Position.findByNote", query = "SELECT p FROM Position p WHERE p.note = :note")})
public class Position implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "PositionId")
    private Integer positionId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 63)
    @Column(name = "PositionName")
    private String positionName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRC")
    private double prc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SRC")
    private double src;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BSC")
    private double bsc;
    @Size(max = 255)
    @Column(name = "Note")
    private String note;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "positionId")
    private Collection<Employee> employeeCollection;
    @JoinColumn(name = "SalaryId", referencedColumnName = "SalaryId")
    @ManyToOne(optional = false)
    private Salary salaryId;

    public Position() {
    }

    public Position(Integer positionId) {
        this.positionId = positionId;
    }

    public Position(Integer positionId, String positionName, double prc, double src, double bsc) {
        this.positionId = positionId;
        this.positionName = positionName;
        this.prc = prc;
        this.src = src;
        this.bsc = bsc;
    }

    public Integer getPositionId() {
        return positionId;
    }

    public void setPositionId(Integer positionId) {
        this.positionId = positionId;
    }

    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public double getPrc() {
        return prc;
    }

    public void setPrc(double prc) {
        this.prc = prc;
    }

    public double getSrc() {
        return src;
    }

    public void setSrc(double src) {
        this.src = src;
    }

    public double getBsc() {
        return bsc;
    }

    public void setBsc(double bsc) {
        this.bsc = bsc;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @XmlTransient
    public Collection<Employee> getEmployeeCollection() {
        return employeeCollection;
    }

    public void setEmployeeCollection(Collection<Employee> employeeCollection) {
        this.employeeCollection = employeeCollection;
    }

    public Salary getSalaryId() {
        return salaryId;
    }

    public void setSalaryId(Salary salaryId) {
        this.salaryId = salaryId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (positionId != null ? positionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Position)) {
            return false;
        }
        Position other = (Position) object;
        if ((this.positionId == null && other.positionId != null) || (this.positionId != null && !this.positionId.equals(other.positionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.Position[ positionId=" + positionId + " ]";
    }
    
}
